package cn.mysdp.biz.controller;


import cn.mysdp.biz.controller.*;
import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: SdpTemplateWebController
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_template
 * Comment:
 * 
 */
@RestController
@RequestMapping(value = "/sdp_template")
public class SdpTemplateWebController extends SdpTemplateWebCustomController {
    static {
        addRequestClass("sdp_template", "add", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateAddRequest.class);
        addRequestClass("sdp_template", "add_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateAddRequest.class);

        addRequestClass("sdp_template", "update", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateUpdateRequest.class);
        addRequestClass("sdp_template", "update_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateUpdateRequest.class);

        addRequestClass("sdp_template", "delete", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateDeleteRequest.class);
        addRequestClass("sdp_template", "delete_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateDeleteRequest.class);

        addRequestClass("sdp_template", "query", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);
        addRequestClass("sdp_template", "query_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);

        addRequestClass("sdp_template", "list", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);
        addRequestClass("sdp_template", "list_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);

        addRequestClass("sdp_template", "count", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);
        addRequestClass("sdp_template", "count_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);

        addRequestClass("sdp_template", "stat", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);
        addRequestClass("sdp_template", "stat_encrypt", "sdpTemplateController", SdpTemplateWebController.class, SdpTemplateQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addSdpTemplate(@RequestBody SdpTemplateAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_template", "add", request, callFromEncrypt);
        return super.addSdpTemplate(request);
    }

    @PostMapping("/add_encrypt")
    public String addSdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateAddRequest request = (SdpTemplateAddRequest) super.decrypt("sdp_template", "add_encrypt", strRequest, SdpTemplateAddRequest.class);
        Integer result = addSdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateSdpTemplate(@RequestBody SdpTemplateUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_template", "update", request, callFromEncrypt);
        return super.updateSdpTemplate(request);
    }

    @PostMapping("/update_encrypt")
    public String updateSdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateUpdateRequest request = (SdpTemplateUpdateRequest) super.decrypt("sdp_template", "update_encrypt", strRequest, SdpTemplateUpdateRequest.class);
        Integer result = updateSdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteSdpTemplate(@RequestBody SdpTemplateDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_template", "delete", request, callFromEncrypt);
        return super.deleteSdpTemplate(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteSdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateDeleteRequest request = (SdpTemplateDeleteRequest) super.decrypt("sdp_template", "delete_encrypt", strRequest, SdpTemplateDeleteRequest.class);
        Integer result = deleteSdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public SdpTemplateQueryResponse querySdpTemplate(@RequestBody SdpTemplateQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("sdp_template", "query", request, callFromEncrypt);
      SdpTemplateQueryResponse result = super.querySdpTemplate(request);
      super.fixResult("sdp_template", "query", request);
      return result;
    }

    @PostMapping("/query_encrypt")
    public String querySdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateQueryRequest request = (SdpTemplateQueryRequest) super.decrypt("sdp_template", "query_encrypt", strRequest, SdpTemplateQueryRequest.class);
        SdpTemplateQueryResponse result = querySdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<SdpTemplateQueryResponse> listSdpTemplate(@RequestBody SdpTemplateQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_template", "list", request, callFromEncrypt);
        List<SdpTemplateQueryResponse> list = super.listSdpTemplate(request);
        super.fixResult("sdp_template", "list", list);
        return list;
    }

    @PostMapping("/list_encrypt")
    public String listSdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateQueryRequest request = (SdpTemplateQueryRequest) super.decrypt("sdp_template", "list_encrypt", strRequest, SdpTemplateQueryRequest.class);
        List<SdpTemplateQueryResponse> result = listSdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countSdpTemplate(@RequestBody SdpTemplateQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("sdp_template", "count", request, callFromEncrypt);
      return super.countSdpTemplate(request);
    }


    @PostMapping("/count_encrypt")
    public String countSdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateQueryRequest request = (SdpTemplateQueryRequest) super.decrypt("sdp_template", "count_encrypt", strRequest, SdpTemplateQueryRequest.class);
        Integer result = countSdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statSdpTemplate(@RequestBody SdpTemplateQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("sdp_template", "stat", request, callFromEncrypt);
        return super.statSdpTemplate(request);
    }

    @PostMapping("/stat_encrypt")
    public String statSdpTemplateEncrypt(@RequestBody String strRequest) throws Exception {
        SdpTemplateQueryRequest request = (SdpTemplateQueryRequest) super.decrypt("sdp_template", "stat_encrypt", strRequest, SdpTemplateQueryRequest.class);
        BaseStatResponse result = statSdpTemplate(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
